<template>
  <div class="flex items-center opp">
   
    <feather-icon icon="TrashIcon" svgClasses="w-5 h-5 hover:text-danger stroke-current" class="ml-2" @click.stop="confirmDeleteRecord(params)" />
  </div>
</template>

<script>
export default {
  name: 'CellRendererOpp',
  data(){
    return{
      delete_id:'',
    }
  },
  methods:{
    editData(row){
      let _this = this;
      _this.$parent.$parent.sidebarData = row.data;
      _this.$parent.$parent.toggleDataSidebar(true);
    },

    editRecord () {
    this.$router.push(`/apps/user/user-edit/${  268}`).catch(() => {})
  },
  confirmDeleteRecord (params) {
    console.log(params);
    this.delete_id = params.data.id;
    this.$vs.dialog({
      type: 'confirm',
      color: 'danger',
      title: '提示',
      text: `确定删除 "${this.params.data.name}"？`,
      accept: this.deleteRecord,
      acceptText: '确定',
      cancelText:'取消'
    })
  },
  deleteRecord () {
    /* Below two lines are just for demo purpose */
    let _this = this;
    _this.$axios({
        url: "/admin/box/delbox",
        method: "post",
        data: {
          id:_this.delete_id
        },
      }).then((res) => {
        //  console.log(res);
        if(res.data.status == 1){
          _this.$parent.$parent.getBoxList();
          _this.showDeleteSuccess()
        }
      });
  

    /* UnComment below lines for enabling true flow if deleting user */
    // this.$store.dispatch("userManagement/removeRecord", this.params.data.id)
    //   .then(()   => { this.showDeleteSuccess() })
    //   .catch(err => { console.error(err)       })
  },
  showDeleteSuccess () {
    this.$vs.notify({
      color: 'success',
      title: '提示',
      text: '删除成功'
    })
  }
  

  }
}
</script>
<style lang="scss">
.opp{
    margin-top:14px;
}
</style>
